package com.demo.shiro.handler;

import com.demo.shiro.utils.ResponseBo;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Jmy
 * @date 2019/8/5 23:20
 * @email jiaomingyu5778@gmail.com
 */
@ControllerAdvice
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class GlobalExceptionHandler {

    @ExceptionHandler(value = AuthorizationException.class)
    public  @ResponseBody ResponseBo handleAuthorizationException() {
        return ResponseBo.error(500, "您没有该操作权限！");
    }
}
